package com.itheima.web; /**
 * @author Xiao
 * @date 2021/8/31
 */

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

@WebServlet("/jsp04")
public class JSPServlet04 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        request.setAttribute("flag", true);
        ArrayList<String> list = new ArrayList<>(
                List.of("张三", "李四", "王五"));
        request.setAttribute("list", list);
        request.getRequestDispatcher("/jsp04.jsp").forward(request, response); //转发
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doGet(request, response);
    }
}
